package demo.DataStrucAndAlgo.Easy_pritice;

import java.util.*;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/9/19-09-19-20:06
 * @Description：demo.DataStrucAndAlgo.Easy_pritice
 */
public class groupAnagrams {
    public static void main(String[] args) {
        double i = 1.1;
        i++;
        System.out.println(i);
       String[] strs = {"eat","tea","tan","ate","nat","bat"};
       // System.out.println(groupAnagrams(strs));
        //System.out.println(Math.pow(2, 10));
    }
    public static List<List<String>> groupAnagrams(String[] strs) {
        List<List<String>> result = new ArrayList();
        if(strs.length == 0){
            return result;
        }
        int size = 0;
        int[][] charStr = new int[strs.length][26];
        int[] path = new int[strs.length];
        for(int i = 0; i < strs.length; i++){
            int j;
            for(j = 0; j < strs[i].length(); j++){
                char c = strs[i].charAt(j);
                charStr[i][c-'a']++;
            }
            j = 0;
            for(j = 0; j < i; j++){
                if(Arrays.equals(charStr[i],charStr[j])){
                    break;
                }
            }
            if(j == i){
                System.out.println(i + "---->" + strs[i]);
                List<String> temp = new ArrayList();
                temp.add(strs[i]);
                path[i] = result.size();
                result.add(temp);
            }else{
                result.get(path[j]).add(strs[i]);
            }

        }

        return result;
    }
}
